Ext.namespace('pages.test.Main');

/**
 * 好好学习
 * */
pages.test.Main = function(config) {
	Ext.apply(this, config);
	this.initUIComponents();
	pages.test.Main.superclass.constructor.call(this);
};

Ext.extend(pages.test.Main, Ext.Panel, {
	/**
	 * 构造函数
	 */
	initUIComponents : function() {
		
		this.fromStore = new Ext.data.Store({
			proxy : new Ext.data.HttpProxy({
				url : ExtJ.getActionPath('zqshcg/loadFdType.do')
			}),
			reader : new Ext.data.JsonReader({
				root : 'data',
				totalProperty : 'total',
				id : 'ID'
			}, [{
				name : 'comName',
				mapping : 'comName'
			}, {
				name : 'comCode',
				mapping : 'comCode'
			}])
		}); 
  		
		this.fromStore.load();
        this.toStore = new  Ext.data.SimpleStore({
				fields : [ 'comName', 'comCode' ],
				data : [[]]
		}); 
		var isForm = new Ext.form.FormPanel({
			width : 500,
			heght : 400,
			tbar : [{
				text : '获得所选的值',
				handler : function(){
					this.onOk();
				}.createDelegate(this)
			}],
            items : [ new Ext.ux.ItemSelector( {     
            	id : 'resourcesList',
                name : "resourcesList",  
                fieldLabel : "资源组分配",  
                hideLabel : true,
                dataFields : ["comCode", "comName"],  
                fromStore : this.fromStore,  
                toStore : this.toStore,  
                msWidth : 400,  
                msHeight : 200,  
                valueField : "comCode",  
                displayField : "comName",  
                toLegend : "已分配资源",  
                fromLegend : "现有资源",  
                toTBar : [{  
                    text : "清除",  
                    handler : function() {  
                    	Ext.getCmp('resourcesList').reset();
                    }  
                }]  
  
            })]
        });
		Ext.apply(this, {
			closeAction : 'close',
			layout : 'fit',
			border : false,
			listeners : {
				'render' : this.initData.createDelegate(this)
			},
			items : [isForm]
		})
	},

	initData : function(){
	},
	onOk : function(){
		alert(Ext.getCmp('resourcesList').getValue());
	}
});